//
//  HeaderView.m
//  Mango
//
//  Created by lanou3g on 16/5/6.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "HeaderView.h"

@interface HeaderView ()
@property (weak, nonatomic) IBOutlet UILabel *titleLbel;

@property (weak, nonatomic) IBOutlet UILabel *timeReadnumLabel;


@end

@implementation HeaderView
static CGFloat height = 0;
- (void)setModel:(DetailModel *)model {
    if (_model != model) {
        _model = model;
    }
    _titleLbel.text = model.title;
    _timeReadnumLabel.text = [NSString stringWithFormat:@"%@",model.publish_time];
    
    NSDictionary *dict = @{NSFontAttributeName : [UIFont systemFontOfSize:20]};
    CGFloat titleLabelWidth = _titleLbel.width;
    CGRect rect = [model.title boundingRectWithSize:CGSizeMake(titleLabelWidth, MAXFLOAT) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dict context:nil];
    height = 15 + rect.size.height + 15 + 16 + 15;
}

+ (CGFloat)heightForHeaderView {
    return height;
}

+ (instancetype)headerView {
    return [[[NSBundle mainBundle]loadNibNamed:@"HeaderView" owner:nil options:nil]lastObject];
}

#pragma mark 切换至夜间模式
- (void)updateToNightSkinMode {
    self.backgroundColor = [UIColor colorWithRed:34/255.0 green:30/255.0 blue:33/255.0 alpha:1.0];
    self.titleLbel.textColor = [UIColor grayColor];
    self.timeReadnumLabel.textColor = [UIColor grayColor];
}

@end
